#include "table.h"

/*==========================================================================*/
/*							MAIN TESTING TABLE								*/
/*==========================================================================*/

int main(){
	//create table
	string name("Test");
	vector<string> attr;
	attr.push_back("attr0");
	attr.push_back("attr1");
	attr.push_back("attr2");
	attr.push_back("attr3");
	vector<int> types;
	types.push_back(STRING);
	types.push_back(STRING);
	types.push_back(STRING);
	types.push_back(INTEGER);
	vector<string> key;
	key.push_back("attr0");
	key.push_back("attr2");
	Table t(name, attr, types, key);
	
	//add tuple
	vector<string> attrs;
	attrs.push_back("tup0Attr0");
	attrs.push_back("tup0Attr1");
	attrs.push_back("tup0Attr2");
	attrs.push_back("45");
	t.addTuple(attrs);
	attrs.clear();

	//add tuple
	attrs.push_back("tup1Attr0");
	attrs.push_back("tup1Attr1");
	attrs.push_back("tup1Attr2");
	attrs.push_back("16");
	t.addTuple(attrs);
	attrs.clear();

	//add tuple
	attrs.push_back("tup2Attr0");
	attrs.push_back("tup2Attr1");
	attrs.push_back("tup2Attr2");
	attrs.push_back("153489478685");
	t.addTuple(attrs);
	attrs.clear();
	
	//print table
	t.print();
	
	//test attrInTuple
	vector<string> attrTest;
	attrTest.push_back("attr1");
	attrTest.push_back("attr3");
	vector<string> valueTest;
	valueTest.push_back("tup0Attr1");
	valueTest.push_back("45");
	cout << "Testing attrIntuple: " << t.attrInTuple(attrTest, valueTest, 0) << "\n\n";
	
	//delete tuple
	cout << "Deleting tuple 0\n";
	vector<string> deleteKey;
	deleteKey.push_back("tup0Attr0");
	deleteKey.push_back("tup0Attr2");
	t.deleteTuple(deleteKey);
	
	//print table
	t.print();
	
	//test attrInTuple again
	cout << "Testing attrIntuple: " << t.attrInTuple(attrTest, valueTest, 0) << "\n\n";
	
	//test getValue
	cout << "Testing getvalue: " << t.getValue("attr1", 1) << "\n\n";
	
	//test getTuple
	vector<string> tupleTest;
	tupleTest = t.getTuple(1);
	cout << "Testing getTuple: ";
	for(int i=0; i<tupleTest.size(); i++){
		cout << tupleTest[i] << "\t";
	}
	cout << "\n\n";	
}
